import ItemMeta from './ItemMeta'

function MenuItem({item, single}) {
  const {children, hidden} = item
  if (hidden) return null
  if (single !== undefined || (children && children.length === 1) || !children) {
    return (
        <el-menu-item index={item.path}>
          <ItemMeta data={item.meta}/>
        </el-menu-item>
    )
  }
  return (
      <el-sub-menu
          index={item.path}
          v-slots={
            {
              title: () => <ItemMeta data={item.meta}/>,
              default: () => children.map(child => <MenuItem item={child} index={child.path}/>)
            }
          }/>
  )
}

export default MenuItem
